﻿using Corina.Common;
using Corina.DataContext.Master;
using Corina.Datamodel.DataObject;
using Corina.Datamodel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Corina.Webservice.Lantern
{
    /// <summary>
    /// Summary description for User
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class User : WebserviceBase
    {

        [WebMethod]
        public ResultInfo Register(string jsonString)
        {
            UserInfo entity = JsonHelper.Parse<UserInfo>(jsonString);
            entity.Password = Utilities.SecurityHelper.GetMd5(entity.Password);
            return GetInstance<UserMaster>().Register(entity);
        }

        [WebMethod]
        public ResultInfo UpdateProfile(string account, string password, string name, string mobile, string email, string linkman, int industryId)
        {
            return GetInstance<UserMaster>().Update(account, password, name, mobile, email, linkman, industryId);
        }

        [WebMethod]
        public ResultInfo UpdatePassword(string account,string password,string newpassword)
        {
            return GetInstance<UserMaster>().UpdatePassword(account, password, newpassword);
        }

        [WebMethod]
        public ResultInfo GetSubusers(string account,string password,int index,int size)
        {
            return GetInstance<UserHypotaxisMaster>().GetSubusers(account, password, index, size);
        }
    }
}
